package com.hlz.flink.chapter06.window;

import com.hlz.flink.chapter05.Event;
import org.apache.flink.streaming.api.functions.windowing.ProcessWindowFunction;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.flink.util.Collector;
import scala.compat.java8.collectionImpl.NextStepper;

/**
 * @author Hongliang Zhu
 * @create 2023-06-23 21:25
 */
public class UrlViewCountResult extends ProcessWindowFunction<Long, UrlViewCount, String, TimeWindow> {
    @Override
    public void process(String url, Context context, Iterable<Long> elements, Collector<UrlViewCount> out) throws Exception {
        // 结合窗口信息，包装输出内容

        Long start = context.window().getStart();
        Long end = context.window().getEnd();

        out.collect(new UrlViewCount(url, elements.iterator().next(), start, end));

    }
}
